#include "../client/Connection.hpp"
#include <memory>

int main()
{
    micromq::Connection::ptr conn = std::make_unique<micromq::Connection>("127.0.0.1", 9090);
    conn->connect();
    
    micromq::Channel::ptr channel = conn->openChannel();
    
    google::protobuf::Map<std::string, std::string> args;
    channel->declareExchange("exchange1", micromq::ExchangeType::TOPIC, true, false, args);
    channel->declareMagQueue("msgQueue1", true, false, false, args);
    channel->declareMagQueue("msgQueue2", true, false, false, args);
    
    channel->bind("exchange1", "msgQueue1", "news.game.EldenRing");
    channel->bind("exchange1", "msgQueue2", "news.music.#");

    for(int i = 0; i < 10; i++) 
    {
        // channel->publishMessage("exchange1", nullptr, "HelloMessage-" + std::to_string(i));
        micromq::BasicProperties bp;
        bp.set_id(micromq::UUIDHelper::getUUID());
        bp.set_mode(micromq::DeliveryMode::DURABLE);
        bp.set_routing_key("news.music.pop");
        channel->publishMessage("exchange1", &bp, "HelloMessage-" + std::to_string(i));
    }

    micromq::BasicProperties bp1;
    bp1.set_id(micromq::UUIDHelper::getUUID());
    bp1.set_mode(micromq::DeliveryMode::DURABLE);
    bp1.set_routing_key("news.music.sport");
    channel->publishMessage("exchange1", &bp1, "HelloMessage-sport");

    micromq::BasicProperties bp2;
    bp2.set_id(micromq::UUIDHelper::getUUID());
    bp2.set_mode(micromq::DeliveryMode::DURABLE);
    bp2.set_routing_key("news.code.debug");
    channel->publishMessage("exchange1", &bp2, "HelloMessage-code");

    conn->closeChannel(channel);

    return 0;
}